/*
 *  Scene.h
 *  c_Render
 *
 *  Created by liao peterson on 11/8/09.
 *  Copyright 2009 uestc. All rights reserved.
 *
 */
#ifndef SCENE_H__
#define SCENE_H__


#include"Macros.h"
#include"Mathutilis.h"
#include"DataStructures.h"
#include"DataStructures.cpp"
#include"GameMeshes.h"
#include"Physics.h"

class Lamp{
public:
	GLfloat *loc;
	GLfloat *rgb;
	GLfloat energy;

	Lamp();
	Lamp(GLfloat*,GLfloat*,GLfloat);
	~Lamp();
};

class Camera{
public:
	//GLfloat *loc;
	//GLfloat *dir;
	vec3	loc;
	vec3	dir;
	Quat	quat;
	vec4	look;
	GLfloat ratio;
	GLfloat near;
	GLfloat far;
	Matrix4x4*World2Camera;
	line finger;
	
	Camera();
	//Camera(GLfloat*,GLfloat*);
	Camera(const vec3&,const vec3&,GLfloat,GLfloat,GLfloat);
	~Camera();
	void SetMatrix();
	void SetMatrix(const GLfloat*pos,const Quat*q);
	// Euler version of rotation transformation
	//void SetMatrixE();
	//void SetMatrixE(const GLfloat*pos,const GLfoat*ori);
	void  updateQuat(GLfloat,GLfloat,GLfloat);
	void  calQuat(GLfloat x,GLfloat y,GLfloat z);
	
	vec3 getLoc(){return loc;}
	//GLfloat*getDir(){return dir;}
	GLfloat getRatio(){return ratio;}
	GLfloat getNear(){return near;}
	GLfloat getFar(){return far;}
	Matrix4x4*getMatrix(){return World2Camera;}
	
	void rotateAroundAxis(const vec3& axis, GLfloat rot);
	void lookAt(const vec3&pt);
	// Only used for finger update in scene.
	void inverseTransform(vec3&pt);
};

class Scene{
public:
	List<Mesh>		*mList;
	List<Camera>	*cList;
	List<Lamp>		*lList;
	line			finger;
#ifdef PHYSICS_MODE
	physicsSimulator *phySim;
#endif
	
	GLuint		*textureIds;

	Scene();
	~Scene();
	void LoadScene(const GLchar*filename);
	// For touching&Eliminating utility
	GLint updateFinger(vec3&pt);
};

#endif